package com.zgjkhis.modules.system.service.impl;

import com.github.pagehelper.PageInfo;
import com.zgjkhis.common.service.impl.BaseServiceImpl;
import com.zgjkhis.common.utils.QueryHelpPlus;
import com.zgjkhis.domain.PageResult;
import com.zgjkhis.modules.system.domain.ConversionFactor;
import com.zgjkhis.modules.system.service.ConversionFactorService;
import com.zgjkhis.modules.system.service.dto.ConversionFactorDto;
import com.zgjkhis.modules.system.service.dto.ConversionFactorQueryCriteria;
import com.zgjkhis.modules.system.service.mapper.ConversionFactorMapper;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @date 2020-05-14
*/
@Service
@AllArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ConversionFactorServiceImpl extends BaseServiceImpl<ConversionFactorMapper, ConversionFactor> implements ConversionFactorService {

    @Override
    public PageResult<ConversionFactorDto> queryAll(ConversionFactorQueryCriteria criteria, Pageable pageable) {
        getPage(pageable);
        PageInfo<ConversionFactor> page = new PageInfo<>(queryAll(criteria));
        return PageResult.data(page, ConversionFactorDto.class);
    }

    @Override
    public List<ConversionFactor> queryAll(ConversionFactorQueryCriteria criteria){
        return baseMapper.selectList(QueryHelpPlus.getPredicate(ConversionFactor.class, criteria));
    }

}
